<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="homepage")
     */
    public function indexAction(Request $request)
    {
        // replace this example code with whatever you need
        return $this->render('default/index.html.twig', [
            'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
        ]);
		}

		/**
		 * @Route("/json", name="json_page")
		 */
		public function jsonAction(Request $request)
		{
			$name = $request->get('name');
			$response = new Response();
			$response->headers->set('content-type', 'application/json');
			$response->setContent(json_encode(['name' => $name]));

			return $response;
		}
}
